<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: AutomataParser::DirectedGraph</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">AutomataParser::DirectedGraph</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/lib/automata_parser/graph_rb.html">
                lib/automata_parser/graph.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000020">add_arc</a>&nbsp;&nbsp;
      <a href="#M000021">del_arc</a>&nbsp;&nbsp;
      <a href="#M000019">new</a>&nbsp;&nbsp;
      <a href="#M000022">walk_from</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000019" class="method-detail">
        <a name="M000019"></a>

        <div class="method-heading">
          <a href="#M000019" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(graph)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000019-source">
<pre>
    <span class="ruby-comment cmt"># File lib/automata_parser/graph.rb, line 36</span>
36:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">graph</span>)
37: 
38:       <span class="ruby-ivar">@vertices_map</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
39:       <span class="ruby-ivar">@inverted_vertices_map</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
40: 
41:       <span class="ruby-identifier">graph</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
42:         <span class="ruby-comment cmt">#output arcs</span>
43:         <span class="ruby-keyword kw">if</span>(<span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">a</span>[<span class="ruby-value">0</span>]]<span class="ruby-operator">==</span><span class="ruby-keyword kw">nil</span>)
44:           <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">a</span>[<span class="ruby-value">0</span>]] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
45:         <span class="ruby-keyword kw">end</span>
46:         <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">a</span>[<span class="ruby-value">0</span>]].<span class="ruby-identifier">push</span>({ <span class="ruby-identifier">a</span>[<span class="ruby-value">2</span>] =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>[<span class="ruby-value">1</span>]})
47:         <span class="ruby-comment cmt">#input arcs</span>
48:         <span class="ruby-keyword kw">if</span>(<span class="ruby-ivar">@inverted_vertices_map</span>[<span class="ruby-identifier">a</span>[<span class="ruby-value">1</span>]]<span class="ruby-operator">==</span><span class="ruby-keyword kw">nil</span>)
49:           <span class="ruby-ivar">@inverted_vertices_map</span>[<span class="ruby-identifier">a</span>[<span class="ruby-value">1</span>]]= <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
50:         <span class="ruby-keyword kw">end</span>
51:         <span class="ruby-ivar">@inverted_vertices_map</span>[<span class="ruby-identifier">a</span>[<span class="ruby-value">1</span>]].<span class="ruby-identifier">push</span>({ <span class="ruby-identifier">a</span>[<span class="ruby-value">2</span>] =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>[<span class="ruby-value">0</span>]})
52:       <span class="ruby-keyword kw">end</span>
53:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000020" class="method-detail">
        <a name="M000020"></a>

        <div class="method-heading">
          <a href="#M000020" class="method-signature">
          <span class="method-name">add_arc</span><span class="method-args">(transiction)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000020-source">
<pre>
    <span class="ruby-comment cmt"># File lib/automata_parser/graph.rb, line 55</span>
55:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_arc</span> <span class="ruby-identifier">transiction</span>
56:       <span class="ruby-comment cmt">#output arcs</span>
57:       <span class="ruby-identifier">trans</span> = <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">0</span>]]
58:       <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">trans!</span>=<span class="ruby-keyword kw">nil</span>)
59:         <span class="ruby-identifier">found</span> = <span class="ruby-keyword kw">false</span>
60:         <span class="ruby-identifier">trans</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
61:           <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">t</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">2</span>]]<span class="ruby-operator">==</span><span class="ruby-identifier">transiction</span>[<span class="ruby-value">1</span>])
62:             <span class="ruby-identifier">found</span> = <span class="ruby-keyword kw">true</span>
63:           <span class="ruby-keyword kw">end</span>
64:         <span class="ruby-keyword kw">end</span>
65:         <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">found</span><span class="ruby-operator">==</span><span class="ruby-keyword kw">false</span>)
66:           <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">0</span>]].<span class="ruby-identifier">push</span>({ <span class="ruby-identifier">transiction</span>[<span class="ruby-value">2</span>] =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">transiction</span>[<span class="ruby-value">1</span>]})
67:         <span class="ruby-keyword kw">end</span>
68:       <span class="ruby-keyword kw">else</span>
69:         <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">0</span>]] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
70:         <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">0</span>]].<span class="ruby-identifier">push</span>({ <span class="ruby-identifier">transiction</span>[<span class="ruby-value">2</span>] =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">transiction</span>[<span class="ruby-value">1</span>]})
71:       <span class="ruby-keyword kw">end</span>
72: 
73:       <span class="ruby-comment cmt">#input arcs</span>
74:       <span class="ruby-identifier">trans</span> = <span class="ruby-ivar">@inverted_vertices_map</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">1</span>]]
75:       <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">trans!</span>=<span class="ruby-keyword kw">nil</span>)
76:         <span class="ruby-identifier">found</span> = <span class="ruby-keyword kw">false</span>
77:         <span class="ruby-identifier">trans</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
78:           <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">t</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">2</span>]]<span class="ruby-operator">==</span><span class="ruby-identifier">transiction</span>[<span class="ruby-value">0</span>])
79:             <span class="ruby-identifier">found</span> = <span class="ruby-keyword kw">true</span>
80:           <span class="ruby-keyword kw">end</span>
81:         <span class="ruby-keyword kw">end</span>
82:         <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">found</span><span class="ruby-operator">==</span><span class="ruby-keyword kw">false</span>)
83:           <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">1</span>]].<span class="ruby-identifier">push</span>({ <span class="ruby-identifier">transiction</span>[<span class="ruby-value">2</span>] =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">transiction</span>[<span class="ruby-value">0</span>]})
84:         <span class="ruby-keyword kw">end</span>
85:       <span class="ruby-keyword kw">else</span>
86:         <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">1</span>]] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
87:         <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">1</span>]].<span class="ruby-identifier">push</span>({ <span class="ruby-identifier">transiction</span>[<span class="ruby-value">2</span>] =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">transiction</span>[<span class="ruby-value">0</span>]})
88:       <span class="ruby-keyword kw">end</span>
89: 
90:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000021" class="method-detail">
        <a name="M000021"></a>

        <div class="method-heading">
          <a href="#M000021" class="method-signature">
          <span class="method-name">del_arc</span><span class="method-args">(transiction)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000021-source">
<pre>
     <span class="ruby-comment cmt"># File lib/automata_parser/graph.rb, line 92</span>
 92:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">del_arc</span> <span class="ruby-identifier">transiction</span>
 93:       <span class="ruby-comment cmt">#output arcs</span>
 94:       <span class="ruby-identifier">trans</span> = <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">0</span>]]
 95:       <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">trans!</span>=<span class="ruby-keyword kw">nil</span>)
 96:         <span class="ruby-identifier">found</span> = <span class="ruby-keyword kw">nil</span>
 97:         <span class="ruby-identifier">trans</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
 98:           <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">t</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">2</span>]]<span class="ruby-operator">==</span><span class="ruby-identifier">transiction</span>[<span class="ruby-value">1</span>])
 99:             <span class="ruby-identifier">found</span> = <span class="ruby-identifier">t</span>
100:           <span class="ruby-keyword kw">end</span>
101:         <span class="ruby-keyword kw">end</span>
102:         <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">found!</span>=<span class="ruby-keyword kw">nil</span>)
103:           <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">0</span>]].<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">found</span>)
104:         <span class="ruby-keyword kw">end</span>
105:       <span class="ruby-keyword kw">end</span>
106: 
107:       <span class="ruby-comment cmt">#input arcs</span>
108:       <span class="ruby-identifier">trans</span> = <span class="ruby-ivar">@inverted_vertices_map</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">1</span>]]
109:       <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">trans!</span>=<span class="ruby-keyword kw">nil</span>)
110:         <span class="ruby-identifier">found</span> = <span class="ruby-keyword kw">nil</span>
111:         <span class="ruby-identifier">trans</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
112:           <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">t</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">2</span>]]<span class="ruby-operator">==</span><span class="ruby-identifier">transiction</span>[<span class="ruby-value">0</span>])
113:             <span class="ruby-identifier">found</span> = <span class="ruby-identifier">t</span>
114:           <span class="ruby-keyword kw">end</span>
115:         <span class="ruby-keyword kw">end</span>
116:         <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">found!</span>=<span class="ruby-keyword kw">nil</span>)
117:           <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">transiction</span>[<span class="ruby-value">1</span>]].<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">found</span>)
118:         <span class="ruby-keyword kw">end</span>
119:       <span class="ruby-keyword kw">end</span>
120: 
121:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000022" class="method-detail">
        <a name="M000022"></a>

        <div class="method-heading">
          <a href="#M000022" class="method-signature">
          <span class="method-name">walk_from</span><span class="method-args">(vertex)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000022-source">
<pre>
     <span class="ruby-comment cmt"># File lib/automata_parser/graph.rb, line 123</span>
123:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">walk_from</span>(<span class="ruby-identifier">vertex</span>)
124: 
125:       <span class="ruby-identifier">arcs</span> = <span class="ruby-ivar">@vertices_map</span>[<span class="ruby-identifier">vertex</span>]
126: 
127:       <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">arcs</span><span class="ruby-operator">==</span><span class="ruby-keyword kw">nil</span>)
128:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
129:       <span class="ruby-keyword kw">else</span>
130:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">build_vertex_wrapper</span>(<span class="ruby-identifier">vertex</span>,<span class="ruby-identifier">arcs</span>)
131:       <span class="ruby-keyword kw">end</span>
132:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>